#pragma once
#include <graphics.h>
#include "vector2.h"
#include "util.h"
#include "TextureAsset.h"
#include "AssetManager.h"
class Texture{
public:
	Texture(TextureAsset*  copy_image ,Vector2 relative_pos = Vector2(0, 0)):image(copy_image),pos(relative_pos){
	}
	//Texture(LPCTSTR pathfile, Vector2 relative_pos = Vector2(0, 0),const std::string& id) {
	//	//graph = new IMAGE;
	//	//loadimage(graph, pathfile);
	//	std::wstring path(pathfile);
	//	image = new TextureAsset(id, path);
	//	pos = relative_pos;
	//}
	~Texture() {}

	void SetPos(Vector2 relative_pos) {
		pos = relative_pos;
	}
	void SetPos(int x, int y) {
		pos.x = x;
		pos.y = y;
	}
	Vector2 GetPos() {
		return pos;
	}

	void RelativeDraw(int x, int y) {
		IMAGE* graph = image->GetImage();
		if (graph) {
			putimage_alpha(x + pos.x, y + pos.y, graph);
		}
	}
	void Draw(Camera& cam) {
		IMAGE* graph = image->GetImage();
		Vector2 position = cam.get_position();

		if (graph) {
			putimage_alpha(cam, pos.x, pos.y, graph);
			pos.x =  position.x;
			pos.y =  position.y;
		}
	}
	bool load() {
		return image->Load();
	}

	void unload() {
		image->Unload();
	}

	int GetWidth() {

		return image->GetWidth();
	}

	bool is_loaded() {
		if (image != nullptr) {
			return false;
		}
		return true;
	}
	int GetHeight() {
		return image->GetHeight();
	}

	IMAGE* GetImage() {
		return image->GetImage();
	}
private:
	//IMAGE* graph = nullptr;
	TextureAsset* image = nullptr;
	Vector2 pos;
};
